package com.huishao.demo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.ZoneId;
import java.util.TimeZone;

/**
 * 启动类
 *
 * @author huishao
 * @since 2023-02-17 13:55:43
 */
@SpringBootApplication
@MapperScan("com.huishao.demo.mapper")
@Slf4j
@EnableScheduling
public class DemoApplication {
    public static void main(String[] args) throws UnknownHostException {
        // 设置时区 解决linux环境下的时区问题！
        TimeZone.setDefault(TimeZone.getTimeZone(ZoneId.SHORT_IDS.get("CTT")));
        Environment env = SpringApplication.run(DemoApplication.class, args).getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        path = path != null ? "/" + path : "";
        log.info("项目启动成功...");
        log.info("接口文档访问地址：http://{}:{}{}/doc.html", ip, port, path);

    }
}

